package cadc.ping;

import java.util.Iterator;
import java.util.List;

import cadc.actions.UserAction;
import cadc.daos.GroupDao;
import cadc.daos.PingDao;
import cadc.models.Group;

@SuppressWarnings("serial")
public class ListAll extends UserAction {
	private GroupDao groupDao;
	private PingDao pingDao;
	private List<Group> groups;
	
	public String execute(){
		groups = groupDao.listBasic();
		Iterator<Group> it = groups.iterator();
		while(it.hasNext()){
			Group g = it.next();
			g.setPings(pingDao.getPingListOfGroup((int) g.getId()));
		}
		return SUCCESS;
	}

	public GroupDao getGroupDao() {
		return groupDao;
	}
	public void setGroupDao(GroupDao groupDao) {
		this.groupDao = groupDao;
	}
	public PingDao getPingDao() {
		return pingDao;
	}
	public void setPingDao(PingDao pingDao) {
		this.pingDao = pingDao;
	}
	public List<Group> getGroups() {
		return groups;
	}
	public void setGroups(List<Group> groups) {
		this.groups = groups;
	}
	
}
